<?php
require_once('Sqlite/DB.php');
$db = openDB('Sqlite/myDatabase');

$url ="http://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$url=str_replace('&',"&amp;",$url);

$rta = queryDB($db,'SELECT Marca, Modelo, fuente FROM Motos JOIN Fotos ON Motos.id_moto =Fotos.id_moto WHERE Motos.id_moto='.$_GET['moto'].' LIMIT 1;');
$rta=getRow($rta);
$fuente=$rta['fuente'];
$marca=$rta['Marca'];
$modelo=$rta['Modelo'];

if(startsWith($fuente,'img/')) //imagen local
	$fuente='http://'.$_SERVER['HTTP_HOST'].path().$fuente;


function startsWith($haystack, $needle)
{
    $length = strlen($needle);
    return (substr($haystack, 0, $length) === $needle);
}
function path(){
	$path = $_SERVER['REQUEST_URI'];
	$length =strrpos($path,'/');
	return substr($path,0,$length+1);
}
?>

<meta property="og:title" content="Catalogo de motos: <?php echo $marca.' '.$modelo; ?>" />
<meta property="og:type" content="product" />
<meta property="og:url" content="<?php echo $url;?>" />
<meta property="og:image" content="<?php echo $fuente;?>" />
<meta property="og:site_name" content="Pagina de motos" />
<meta property="fb:app_id" content="100000382540770" />
